﻿using System;
using Glue;
using Glue.Converters;
using Glue.Internals;
using GlueTests.Builders;
using Xunit;

namespace GlueTests
{
    public class CollectionMappingTest
    {
        private readonly CollectionMapping mapper;

        public CollectionMappingTest()
        {
            var intArrayProperty = (ICollectionMember)PropertyBuilder.AsIntArrayProperty().Build();
            mapper = new CollectionMapping(intArrayProperty, intArrayProperty, new SameTypeMapping(typeof(int)),new CreatorContainer());
        }

        [Fact]
        public void Should_throw_exception_if_from_object_is_not_an_IGlueCollection()
        {
            Assert.Throws(typeof(GlueException),()=>mapper.Map(1, null));
        }

        [Fact]
        public void Should_accept_null_when_mapping()
        {
            mapper.Map(null, null);
        }

    }
}
